<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head> 
    <meta charset="UTF-8">
    <%@ include file="/WEB-INF/views/include/head.jsp"%>
    <link rel="stylesheet" href="${ctxStatic}/css/common_erp.css">
    <link rel="stylesheet" href="${ctxStatic}/css/layerSm.css">
    <script>
    $(document).ready(function(){
        var form = $("#inputForm");  
        form.validate();//验证指定的表单
        $("#ognizationCategoryCd").select2();
        $("#ognizationLevelCd").select2();
        $("#ognizationCountry").select2();
        $("#ognizationCity").select2();
        
        $("#confirmBtn").click(function(){
           if (form.valid()) {//如果表单验证成功，则进行提交。  
               $("#showHtml").addClass("showHtml");
               $("#confirmPage").css("display","block");
               $("#editPage").css("display","none");
               $('.showHtml').find('input,select,textarea').attr('disabled',true);
               return false;
           }
         });
        
        $("#backBtn").click(function(){
            $("#showHtml").removeClass("showHtml");
            $("#confirmPage").css("display","none");
            $("#editPage").css("display","block");
            $('#inputForm').find('input,select,textarea').attr('disabled',false);
            return false;
          });
    });
    
    //保存方法
    var saveForm={
         t:null,
         save:function(t){
        	 $('.showHtml').find('input,select,textarea').attr('disabled',false);
             $(t).attr("disabled",true);
             this.t=t;
      	     var params = $("#inputForm").serialize();
             $.post("${ctx}/fabricating/message/save",params,function(result){
            	 // 提示信息
                 tipParent(result.message);
                 // 返回状态
                 if(result.statusCode==STATUSCODEOK){
                    // 刷新页面
                    window.parent.frames[0].searchListForm();
                    closeWin(); 
                 }else{
                      $(saveForm.t).attr("disabled",false);
                 }
             },'json');
         } 
    }
    
    //城市联动
    function cityFun(t,id){
        var code=$(t).find("option:selected").attr("data-value");
        var param={"code":code};
        $.post("${ctx}/fabricating/message/city",param,function(result){
            var html="<option value=''><spring:message code="fabricating_saveCity"/></option>";
            $.each(result,function(i,e){
                html+="<option value='"+e.itemCode+"-"+e.itemValue+"'>"+e.itemName+"</option>";
            });
            $("#"+id).html(html);
            $("#"+id).select2();
        },'json');
    }
    

    </script> 
</head>
<body>
    <!-- 创建页面head部 -->
	<div id="editPage" class="layerHeader clearfix">
	    <c:choose>
	        <c:when test="${ognization.id!=null && ognization.id!=''}">
	             <!-- 修改编辑 -->
	            <p class="headerTitle"><spring:message code="fabricating_head_edit_fabricating_info"/></p>
	        </c:when>
	        <c:otherwise>
	             <!-- 新建 -->
	            <p class="headerTitle"><spring:message code="fabricating_head_create_fabricating_info"/></p>
	        </c:otherwise>
	    </c:choose>

	    <div class="headerButton clearfix">
	        <button type="button" id="confirmBtn"><spring:message code="btn_ok"/></button>
	        <button type="button" onclick="closeWin()"><spring:message code="btn_cancle"/></button>
	    </div>
	</div>
	
	<form id="inputForm" method="post" >
	<c:set value="<%=ResourcesUtil.getConfig(\"fabricating_level\")%>" var="fabricatingLevel" />
	<c:set value="<%=ResourcesUtil.getConfig(\"fabricating_category\")%>" var="fabricatingCategory" />
    <c:set value="<%=ResourcesUtil.getConfig(\"fabricating_country\")%>" var="fabricatingCountry" />
	
	<input type="hidden" id="id" name="id" value="${ognization.id}"/>
	<input type="hidden" id="ognizationCode" name="ognizationCode" value="${ognization.ognizationCode}"/>
	
	<!-- 确认页面head部 -->
	<div id="confirmPage" class="layerHeader clearfix" style="display:none">
		<p class="headerTitle"><spring:message code="fabricating_head_confirm_fabricating_info"/></p>
	    <div class="headerButton clearfix">
	        <shiro:hasPermission name="fabricating:message:edit">
	        <button type="button" id="saveBtn" onclick="saveForm.save(this)"><spring:message code="common_save"/></button>
	        </shiro:hasPermission>
	        <button type="button" id="backBtn"><spring:message code="fabricating_btn_cancel"/></button>
	    </div>
	</div>
	
    <div id="showHtml">
    	<div class="smList">
    	    <c:if test="${ognization.id!=null && ognization.id!=''}">
            <div class="items clearfix">
	        	<div class="col-50 clearfix">
	                <p class="tit"><spring:message code="fabricating_code"/></p>
	                <p>${ognization.ognizationCode}</p>
	            </div>
	        </div>
	        </c:if> 
	        <div class="items clearfix">
	        	<div class="col-50 clearfix haveToBox">
	                <p class="tit"><spring:message code="fabricating_name"/></p>
	                <input type="text" maxlength="20" id="ognizationName" name="ognizationName" value="${ognization.ognizationName}" data-rule-required="true" data-msg-required="<spring:message code="fabricating_err_msg_name"/>">
	                <p class="haveTo">*</p>
	            </div>
	            <div class="col-50 right clearfix haveToBox">
	                <p class="tit"><spring:message code="fabricating_fabricating_category"/></p>
	                <select style="width:43%" id="ognizationCategoryCd" name="ognizationCategoryCd" data-rule-required="true" data-msg-required="<spring:message code="fabricating_err_msg_category"/>" >
                       <option value=""><spring:message code="fabricating_pleaseChoose"/></option>
                           <c:forEach items="${fns:getDictList(fabricatingCategory)}"   var="category">
                               <option <c:if test="${fn:split(ognization.ognizationCategoryCd,'-')[1] eq category.itemValue}">selected="selected"</c:if> value="${category.itemCode}-${category.itemValue}" > 
                                   ${category.itemName}
                               </option>
                           </c:forEach>
                    </select>
                    <p class="haveTo">*</p>
	            </div>
	        </div>
	        <div class="items clearfix">
	        	<div class="col-50 clearfix haveToBox">
	                <p class="tit"><spring:message code="fabricating_simple_name"/></p>
	                <input type="text" maxlength="4" id="ognizationSimpleName" name="ognizationSimpleName" value="${ognization.ognizationSimpleName}" data-rule-required="true" data-msg-required="<spring:message code="fabricating_err_msg_simple_name"/>" data-rule-lettersnumbers="true" data-msg-lettersnumbers="<spring:message code="material_pleaseInput_banjiao" />">
	                <p class="haveTo">*</p> 
	            </div>
	            <div class="col-50 right clearfix haveToBox">
	                <p class="tit"><spring:message code="fabricating_fabricating_level"/></p>
                       <select style="width:43%" id="ognizationLevelCd" name="ognizationLevelCd" data-rule-required="true" data-msg-required="<spring:message code="fabricating_err_msg_level"/>" >
                       <option value=""><spring:message code="fabricating_pleaseChoose"/></option>
                           <c:forEach items="${fns:getDictList(fabricatingLevel)}"   var="level">
                               <option <c:if test="${fn:split(ognization.ognizationLevelCd,'-')[1] eq level.itemValue}">selected="selected"</c:if> value="${level.itemCode}-${level.itemValue}" > 
                                   ${level.itemName}
                               </option>
                           </c:forEach>
                       </select>
                       <p class="haveTo">*</p>
	            </div>
	        </div>
	        <div class="items clearfix">
	        	<div class="col-50 clearfix haveToBox">
	                <p class="tit"><spring:message code="fabricating_country"/></p>
                    <select style="width:43%" id="ognizationCountry" name="ognizationCountry" onchange="cityFun(this,'ognizationCity')" data-rule-required="true" data-msg-required="<spring:message code="fabricating_savecountry"/>">
                           <option value=""><spring:message code="fabricating_savecountry"/></option>
                           <c:forEach items="${fns:getDictList(fabricatingCountry)}" var="country">
                               <option data-value="${country.itemValue}" <c:if test="${fn:split(ognization.ognizationCountry,'-')[1] eq country.itemValue}">selected="selected"</c:if> value="${country.itemCode}-${country.itemValue}">
                                     ${country.itemName}
                               </option>
                           </c:forEach>                    
                    </select>
                    <p class="haveTo">*</p>
	            </div>
	            <div class="col-50 right clearfix haveToBox">    
	                <p class="tit"><spring:message code="fabricating_city"/></p>
                    <select style="width:43%" id="ognizationCity" name="ognizationCity" data-rule-required="true" data-msg-required="<spring:message code="fabricating_saveCity"/>">
                        <option value=""><spring:message code="fabricating_saveCity"/></option>
                        <c:forEach items="${fns:getDictList(fn:split(ognization.ognizationCountry,'-')[1])}" var="city">
                          <option <c:if test="${fn:split(ognization.ognizationCity,'-')[1] eq city.itemValue}">selected="selected"</c:if> value="${city.itemCode}-${city.itemValue}">
                              ${city.itemName}
                          </option>
                        </c:forEach>                                            
                    </select>
                    <p class="haveTo">*</p>
	            </div>
	        </div>
	        <div class="items clearfix">
	        	<div class="col-50 clearfix">
	                <p class="tit"><spring:message code="fabricating_fabricating_address"/></p>
	                <input type="text" maxlength="50" id="ognizationAddress" name="ognizationAddress" value="${ognization.ognizationAddress}">
	            </div>
	            <div class="col-50 right clearfix">
	                <p class="tit"><spring:message code="fabricating_fabricating_zipcode"/></p>
	                <input type="text" maxlength="10" id="ognizationZipCode" name="ognizationZipCode" value="${ognization.ognizationZipCode}">
	            </div>
	        </div>
	        <div class="items clearfix">
	        	<div class="col-50 clearfix">
	                <p class="tit"><spring:message code="fabricating_description"/></p>
	                <textarea maxlength="100" Style="width:43%" id="ognizationDescription" name="ognizationDescription" value="${ognization.ognizationDescription}">${ognization.ognizationDescription}</textarea>
	            </div>
	            <div class="col-50 right clearfix items">
	                <p class="tit"><spring:message code="fabricating_contact_person"/></p>
	                <input type="text" maxlength="20"  id="contactPerson" name="contactPerson" value="${ognization.contactPerson}">
	            </div>
	            <div class="col-50 right clearfix">
	                <p class="tit"><spring:message code="fabricating_contact_phone"/></p>
	                <input type="text" maxlength="15" id="contactPhone" name="contactPhone" value="${ognization.contactPhone}">
	            </div>
	        </div>
	        <div class="items clearfix">
	        	<div class="col-50 clearfix haveToBox">
	                <p class="tit"><spring:message code="fabricating_bankAccount"/></p>
	                <input type="text" maxlength="20" id="bankName" name="bankName" value="${ognization.bankName}" data-rule-required="true" data-msg-required="<spring:message code="fabricating_err_msg_bank"/>">
	                <p class="haveTo">*</p>
	            </div>
	            <div class="col-50 right clearfix">
	                <p class="tit"><spring:message code="fabricating_fax"/></p>
	                <input type="text" maxlength="15" id="contactFax" name="contactFax" value="${ognization.contactFax}">
	            </div>
	        </div>
	        <div class="items clearfix">
	        	<div class="col-50 clearfix haveToBox">
	                <p class="tit"><spring:message code="fabricating_bankAccountNO"/></p>
	                <input type="text" maxlength="25" id="bankAccountNo" name="bankAccountNo" value="${ognization.bankAccountNo}" data-rule-required="true" data-msg-required="<spring:message code="fabricating_err_msg_bank_no"/>">
	                <p class="haveTo">*</p>
	            </div>
	            <div class="col-50 right clearfix">
	                <p class="tit"><spring:message code="fabricating_emial"/></p>
	                <input type="text" maxlength="100" id="contactEmail" name="contactEmail" value="${ognization.contactEmail}" data-rule-email="true"  data-msg-email="<spring:message code="user_saveEmail"/>">
	            </div>
	        </div>
	        <div class="items clearfix">
	        	<div class="col-50 clearfix">
	                <p class="tit"><spring:message code="fabricating_creater"/></p>
	                <p>${ognization.createBy.firstName}${ognization.createBy.lastName}</p>
	            </div>
	            <div class="col-50 right clearfix">
	                <p class="tit"><spring:message code="fabricating_create_date"/></p>
	                <p><fmt:formatDate value="${ognization.createDate}" pattern="yyyy-MM-dd HH:mm" /></p>
	            </div>
	        </div>
		</div> 
	</div> 	
	</form>
</body>
</html>